// f[i][j][k] = max(f[i - 1][j][k], f[i - 1][j - v][k - w] + value)
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 110;
int f[N][N], n, v, m;

int main()
{
    cin >> n >> v >> m;
    while (n--)
    {
        int vi, mi, wi;
        cin >> vi >> mi >> wi;
        for (int j = v; j >= vi; --j)
            for (int k = m; k >= mi; --k)
                f[j][k] = max(f[j][k], f[j - vi][k - mi] + wi);
    }
    cout << f[v][m] << endl;
}